package com.wuxi.scheduler.controller;

import com.wuxi.common.log.annotation.OperationLog;
import com.wuxi.scheduler.pojo.seer.AdditionalJSON;
import com.wuxi.scheduler.pojo.seer.SeerResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@Tag(name = "仙工AGV回调")
@RequestMapping()
@RequiredArgsConstructor
public class SeerPostActionController {

    @OperationLog
    @Operation(summary ="动作块执行完成上报信息")
    @PostMapping("/echo")
    public SeerResponse  bindAgvRobot(@RequestBody AdditionalJSON additionalJSON) {

        try {
            // 处理上报数据
            log.info("收到动作块上报数据:{} ",additionalJSON);


            // 验证必要字段
            if (additionalJSON.getOrderId() == null) {
                return null;
            }

            return SeerResponse.ok();

        } catch (Exception e) {
            log.error(e.getMessage());
            return null;
        }
    }

}
